<h2><?php echo $category->name; ?></h2>
<?php if(Arr::get($errors, 'quantity')):?>
<?php echo Form::label('error', Arr::get($errors, 'quantity'), array('class' => 'error'));?>
<?php endif;?>
<table>
<tr>
	<th>Item Number</th>
	<th>Item Name</th>
	<?php foreach($attributes as $attr):?>
	<?php echo '<th>'.$attr->name.'</th>'?>
	<?php endforeach;?>
	<th>Quantity In Stock</th>
	<th>Restock Price</th>
	<th>Quantity To Order</th>
<tr>

<?php
foreach($inv_items as $items):
	foreach($items as $item):
		echo '<tr>';
		echo '<td>'.$item->id.'</td>';
		echo '<td>'.$item->item->name.'</td>';
		foreach($attributes as $attr) :
			$inv_attr = ORM::factory('inventoryItemAttribute')
				->where('inventory_item_id', '=', $item->id)
				->where('attribute_id', '=', $attr->id)
				->find();
			if($inv_attr->value->value !== NULL) {
				echo '<td>'.$inv_attr->value->value.'</td>';
			}
			else {
				echo '<td>N/A</td>';
			}
		endforeach;
	  	echo '<td>'.$item->quantity.'</td>';
	  	echo '<td>'.money_format('%n', $item->item->restock_price).'</td>';
	  	echo '<td>';
	  	echo Form::open('admin/merchmanagement/inventory/edit/'.$category->id);
	  	echo Form::hidden('inventoryitem_id', $item->id);
	  	echo Form::hidden('restock_price', $item->item->restock_price);
	  	echo Form::input('quantity', 0);
	  	echo Form::submit('submit', 'Order');
	  	echo Form::close();
	  	echo '</td>';
		echo '</tr>';
	endforeach;
endforeach;
?>
</table>

<?php echo Html::anchor('admin/merchmanagement/inventory', 'Back to Inventory');?>